import axios from '@/utils/request';

/**
 * 新增提成方案
 */
export async function AddCommission(params) {
    const res = await axios.post('/Commission/AddCommission',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取提成方案查询分页列表
 */
 export async function QueryCommissionPageList(params) {
    const res = await axios.post('/Commission/QueryCommissionPageList',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id获取提成方案
 */
 export async function GetCommissionById(id) {
    const res = await axios.get('/Commission/GetModelById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id获取提成方案
 */
export async function QueryCommissionLogByCondition(id) {
    const res = await axios.get('/Commission/QueryCommissionLogByCondition/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 更新提成方案
 */
 export async function UpdateCommission(params) {
    const res = await axios.post('/Commission/UpdateCommission',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  * 修改提成方案状态信息
  */
 export async function UpdateStatus(params) {
    const res = await axios.post('/Commission/UpdateStatus',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
  }

  /**
 * 根据产品类型获取提成方案
 */
export async function QueryCommissionByProductTypeId(id) {
    const res = await axios.get('/Commission/QueryCommissionByProductTypeId?productTypeId='+id);
    return res.data;
}

  /**
 * 根据销售数量获取提成方案
 */
  export async function QueryCommissionBySaleQty(saleqty) {
    const res = await axios.get('/Commission/QueryCommissionBySaleQty?saleqty='+saleqty);
    return res.data;
}
/**
 * 作废提成方案
 */
export async function DeleteCommission(id) {
    const res = await axios.post('/Commission/DeleteCommission?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}